package com.lovo;

import javax.swing.*;
import java.awt.*;
import java.lang.invoke.SwitchPoint;

public class Test0 extends JFrame {
    private CardLayout cardLayout = new CardLayout();
    private menu menu1 = new menu(this);
    private login log1 = new login(this);
    private Image image1 = Util.getImage("/img/background.jpg");



    public Test0() {
        //传入背景图
        this.setContentPane(new JPanel() {
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                g.drawImage(image1, 0, 0, 1024, 768, this);
            }
        });


        //卡片
        this.setLayout( cardLayout);
        this.add("login", log1);
        this.add("menu", menu1);



        //窗口体大小
        this.setSize(1024, 768);
        //居中
        this.setLocationRelativeTo(null);
        //关闭内存
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        //窗口可视化
        this.setVisible(true);
    }


    public void switchPanel(String name){
        cardLayout.show(this.getContentPane(),name);
    }

    public static void main(String[] args) {
        new Test0();
    }
}
